<?php

namespace app\api\controller;

use think\facade\Request;
use app\common\Common;
use app\api\service\WechatService;
use think\facade\Cache;
use think\facade\Db;
use think\facade\Log;
class Baidu extends Base
{
    private $service;

    public function __construct(WechatService $service)
    {
        $this->service = $service;
    }

    // 百度回传数据
    public function baidufrom()
    {
        $params = Request::param();
        // file_put_contents('./baidu_monitoring_link.txt', date('Y-m-d H:i:s').' ：'.json_encode($params).';'.PHP_EOL, FILE_APPEND);

        $logidUrl = $params['url'].'&video='.$params['video_id'].'&video_detail_id='.$params['video_detail_id'].'&type=3&bd_vid='.$params['bd_vid'];

        // 百度
        $url = 'https://ocpc.baidu.com/ocpcapi/api/uploadConvertData';
        $conversionTypes = [
            'logidUrl' => $logidUrl,
            'newType' => intval($params['type']), // 付费观剧:118 https://dev2.baidu.com/content?sceneType=0&pageId=101207&nodeId=655
            'convertValue' => 1
        ];

        $token = $params['token'];
        $datas = ['token' => $token, 'conversionTypes' => $conversionTypes];
        $requestData = json_encode($datas);
        $result = Common::curlRequest($url, 'POST', $requestData, ['Content-Type : application/json']);
        dump($result);die;
    }
}